package hu.kisprof.quiz.view.panels;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import hu.kisprof.quiz.view.Labels;
import hu.kisprof.quiz.view.QuizGUI;

public class QuizStatisticPanel extends JPanel implements ActionListener{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8487194118375222482L;
	private QuizGUI gui;
	private JButton okButton;
	private JTable jTbl;
	
	
	public QuizStatisticPanel(QuizGUI gui,DefaultTableModel st){
		this(gui, new JTable(st));
	}
	
	public QuizStatisticPanel(QuizGUI gui, String[][] table,String[] columnNames){
		this(gui, new JTable(table,columnNames));
		
	}
	public QuizStatisticPanel(QuizGUI gui, JTable tbl){
		super(new BorderLayout());
		this.gui=gui;
		JPanel tmp = new JPanel(new FlowLayout(FlowLayout.CENTER));
		okButton =new JButton(Labels.ok);
		okButton.addActionListener(this);
		tmp.add(okButton);
		this.add(tmp,BorderLayout.SOUTH);
		
		
		
		
		this.jTbl=tbl;
		jTbl.setEnabled(false);
		this.add(jTbl,BorderLayout.CENTER);
		
		
		
		
	}


	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals(Labels.ok)){
			gui.setActualContent(new QuizRoomChoosePanel(gui));
		}
		
	}
	
	
	
}
